home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / ODF / OS / FWGraphx / SLColor.h < prev    next >
Encoding:
Text File  |  1996-12-16  |  2.8 KB  |  116 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                SLColor.h
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef SLCOLOR_H
  11. #define SLCOLOR_H
  12.  
  13. #ifndef SLGRDEF_H
  14. #include "SLGrDef.h"
  15. #endif
  16.  
  17. // Export or Import functions for CFM-68K [sfu]
  18.  
  19. #if defined(FW_ODFLIB_IMPORT)
  20. #pragma import on
  21. #elif defined(FW_ODFLIB)
  22. #pragma export on
  23. #endif
  24.  
  25. FW_EXTERN_C_BEGIN
  26.  
  27. //========================================================================================
  28. // Type definitions
  29. //========================================================================================
  30.  
  31. typedef unsigned char FW_RGBComponent;
  32.  
  33. struct    FW_SColor
  34. {
  35.     unsigned long    fRGB;
  36. };
  37.  
  38. //========================================================================================
  39. // Color utilities
  40. //========================================================================================
  41.  
  42. inline void FW_PrivSetRGB(FW_SColor& color, FW_RGBComponent r, FW_RGBComponent g, FW_RGBComponent b)
  43. {
  44.     color.fRGB = (((unsigned long)(r)) | ((unsigned long)(g) << 8) | ((unsigned long)(b) << 16));
  45. }
  46.  
  47. inline FW_RGBComponent FW_PrivRGB_R(const FW_SColor& color)
  48. {
  49.     return (FW_RGBComponent) (color.fRGB);
  50. }
  51.  
  52. inline FW_RGBComponent FW_PrivRGB_G(const FW_SColor& color)
  53. {
  54.     return (FW_RGBComponent) (color.fRGB >> 8);
  55. }
  56.  
  57. inline FW_RGBComponent FW_PrivRGB_B(const FW_SColor& color)
  58. {
  59.     return (FW_RGBComponent) (color.fRGB >> 16);
  60. }
  61.  
  62. FW_Boolean    operator==(const FW_SColor& color1, const FW_SColor& color2);
  63. FW_Boolean    operator!=(const FW_SColor& color1, const FW_SColor& color2);
  64.  
  65. inline FW_Boolean    operator==(const FW_SColor& color1, const FW_SColor& color2)
  66. {
  67.     return color1.fRGB == color2.fRGB;
  68. }
  69.  
  70. inline FW_Boolean    operator!=(const FW_SColor& color1, const FW_SColor& color2)
  71. {
  72.     return color1.fRGB != color2.fRGB;
  73. }
  74.  
  75. //========================================================================================
  76. // Color conversion functions
  77. //========================================================================================
  78.  
  79. #ifdef FW_BUILD_WIN
  80.  
  81. FW_SColor        SL_API
  82. FW_WinRGBQuadToColor(const RGBQUAD* rgbQuad);
  83.  
  84. FW_SColor        SL_API
  85. FW_WinRGBTripleToColor(const RGBTRIPLE* rgbTriple);
  86.  
  87. void            SL_API
  88. FW_WinColorToRGBQuad(FW_SColor rgb, RGBQUAD* rgbQuad);
  89.  
  90. void            SL_API
  91. FW_WinColorRGBTriple(FW_SColor rgb, RGBTRIPLE* rgbTriple);
  92.  
  93. #endif
  94.  
  95. #ifdef FW_BUILD_MAC
  96.  
  97. FW_SColor        SL_API
  98. FW_MacRGBToColor(const RGBColor* rgbColor);
  99.  
  100. void            SL_API
  101. FW_MacColorToRGB(FW_SColor rgb, RGBColor* rgbColor);
  102.  
  103. #endif
  104.  
  105. FW_EXTERN_C_END
  106.  
  107. // For CFM-68K [sfu]
  108.  
  109. #if defined(FW_ODFLIB_IMPORT)
  110. #pragma import off
  111. #elif defined(FW_ODFLIB)
  112. #pragma export off
  113. #endif
  114.  
  115. #endif // SLCOLOR_H
  116.